package org.getoffer.shortlink.admin.toolkit;


import java.util.Random;

/**
 * 分组ID随机生成器
 */
public final class RandomGenerator {

    private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    private static final int LENGTH = 6;

    /**
     * 生成包含数字和字母的6位随机字符串
     * @return 随机字符串
     */
    public static String generateRandomString() {
        StringBuilder result = new StringBuilder(LENGTH);
        Random random = new Random();

        for (int i = 0; i < LENGTH; i++) {
            int index = random.nextInt(CHARACTERS.length());
            result.append(CHARACTERS.charAt(index));
        }
        return result.toString();
    }

    public static void main(String[] args) {
        // 测试生成随机字符串
        for (int i = 0; i < 5; i++) {
            System.out.println(generateRandomString());
        }
    }
}
